package reflect;

import java.lang.reflect.Field;
import java.util.Arrays;

public class Test3 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Teacher");
        Object obj = cls.newInstance();

        Field field = cls.getDeclaredField("gender");
        field.setAccessible(true);
        field.set(obj,'男');
        System.out.println(obj);


        String s1 = "123abc";
        String s2 = "123abc";
        Class cl = String.class;
        Field f = cl.getDeclaredField("value");
        f.setAccessible(true);
        char[] value = (char[])f.get(s1);
        System.out.println(Arrays.toString(value));
        value = new char[]{'h','e','l','l','o'};
        f.set(s1,value);
        System.out.println(s1);
        System.out.println(s2);
        String s3 = "123abc";
        System.out.println(s3);
    }
}
